package com.zyh.system.supermark1.dao.impl;

import com.zyh.system.supermark1.dao.UserDao;
import com.zyh.system.supermark1.domain.User;

import java.util.LinkedList;

public class UserDaoImpl implements UserDao {
    public static LinkedList<User> USER_LIST =new LinkedList<>();

    static {
        USER_LIST.add(new User("admin", "123456", "张三", 24));
    }

    @Override
    public LinkedList<User> find() {
        return USER_LIST;
    }

    @Override
    public void register(LinkedList<User> list, User user) {
        list.add(user);
    }

    public User login(User user) {
        User loginUser = null;
        for (User user1 : USER_LIST) {
            if (user1.getUserName().equals(user.getUserName()) && user1.getPassWord().equals(user.getPassWord())) {
                loginUser = user1;
                break;
            }
        }
        return loginUser;
    }
}